package com.lz.ht.service.serviceImpl;

import com.lz.ht.dao.IncreaseDao;
import com.lz.ht.dao.RoomDao;
import com.lz.ht.model.Increase;
import com.lz.ht.page.PageModel;
import com.lz.ht.service.IncreaseService;
import com.lz.ht.util.ToolKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassName: IncreaseServiceImpl
 * @Description:
 * @Author: CHonghao
 * @Date: 2021/7/12 8:25
 * @Version: V1.0
 **/

@Service
@Transactional(rollbackFor = Exception.class)
public class IncreaseServiceImpl  implements IncreaseService {

    @Autowired
    private IncreaseDao increaseDao;
    @Override
    public List<Increase> findPageList(PageModel<Increase> page, Increase increase) throws Exception {
        HashMap<String, Object> hashMap = ToolKit.javaBeanToMap(increase);
        hashMap.put("msFirst", page.getMsFirst());
        hashMap.put("msLast", page.getMsLast());
        return increaseDao.findListByMapLimit(hashMap);
    }

    @Override
    public long findCount(Increase increase) throws Exception {
        HashMap<String, Object> hashMap = ToolKit.javaBeanToMap(increase);
        return increaseDao.findCountByMap(hashMap);
    }

    @Override
    public void add(Increase increase) {
        increaseDao.add(increase);
    }

    @Override
    public Increase findById(Integer ino) {
        return increaseDao.selectByPrimaryKey(ino);
    }

    @Override
    public void updateById(Increase increase) {
        increaseDao.updateByPrimaryKeySelective(increase);
    }

    @Override
    public void deleteById(Integer ino) {
        increaseDao.deleteByPrimaryKey(ino);
    }
}
